package top.zackyoung.internationalization;

import cn.hutool.extra.spring.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ZackYoung
 * @version 1.0
 * @description
 * @date 2021/6/4 15:06
 */
@SpringBootApplication
@RestController
public class InternationalizationApplication {
    public static void main(String[] args) {
        SpringApplication.run(InternationalizationApplication.class, args);
    }

    @Resource
    private MessageSource messageSource;

    @GetMapping("/test")
    public String testInfo() {
//        return messageSource.getMessage("hello", null, LocaleContextHolder.getLocale());
        return SpringUtil.getBean(MessageSource.class).getMessage("hello", null, LocaleContextHolder.getLocale());
    }
}